#ifndef OBJECTCOUNTERDLG_H
#define OBJECTCOUNTERDLG_H

#include <QWidget>
#include "cvutils.h"
#include <array>

namespace Ui {
class ObjectCounterDlg;
}

class CounterThread : public std::enable_shared_from_this<CounterThread>{
public:
    CounterThread(CvUtils::objectCounter* counter = nullptr);
    ~CounterThread();
    QThread* thread() {return _cnt_thread;}
private:
    QThread* _cnt_thread;
};

class ObjectCounterDlg : public QWidget
{
    Q_OBJECT

public:
    explicit ObjectCounterDlg(QWidget *parent = nullptr);
    ~ObjectCounterDlg();
    void showCountRes(const char* imagePath);

public slots:
    void process(const ObjectInfo& objInfo);//将object中的信息绘制在PreView上

private slots:
    void on_comboBox_activated(int index);

private:
    Ui::ObjectCounterDlg *ui;
    CvUtils::objectCounter m_counter;
    std::unique_ptr<CounterThread> m_cntThread;
    QPixmap m_background;
    std::array<std::pair<bool, ObjectInfo>, 2> m_objInfoCached;
};

#endif // OBJECTCOUNTERDLG_H
